from flask import Blueprint
from utils.comm import get_data
bp_auser = Blueprint('adminuser',__name__)

@bp_auser.route('/roleM',methods=['POST','GET'])
def roleM():
    #获取参数
    data = get_data()
    #判断角色是否重复
    sql = 'select id from roles where name="%s"'%(data['name'])
    res = db1.find(sql)
    if res:
        #存在返回错误信息
        return jsonify({'code':20010})
    else:
        sql1 = 'insert into roles values(0,"%s")'%(data['name'])
    #不存在添加
    db1.updata(sql1)
    return jsonify('code':2000)

